package r21310.chap04.d1002;

import java.time.LocalDateTime;
import java.util.Random;
import java.util.Scanner;
public class BookStore {
        static book1[] books = new book1[4];


        static {
            books[0] = new book1(1, "红楼梦", 50, 20);
            books[1] = new book1(2, "水浒传", 40, 10);
            books[2] = new book1(3, "三国演义", 30, 10);
            books[3] = new book1(4, "西游记", 20, 10);
        }

        public static void main(String[] args) {
            showbook1(books);
            Person p=new Person("张飞");
            book1 book=p.buybook1(books);
            showTotal(book,p);

        }

        private static void showbook1(book1[] books) {
            System.out.println("图书编号  图书名称  图书价格  库存数量");
            for (int i = 0; i < 4; i++) {
                System.out.println(books[i].getId()+"\t\t"+books[i].getName()+"\t\t"+books[i].getPrice()+"\t\t"+books[i].getStorage());

            }
        }

        public static void showTotal(book1 book,Person p) {
            Scanner sc=new Scanner(System.in);
            for (int i = 0; i < 4; i++) {


            }


            Random random=new Random();
            int orderNum=random.nextInt();
            System.out.println("订单编号"+Math.abs(orderNum));
            System.out.println("购物时间"+ LocalDateTime.now());
            System.out.println("会员"+p.getName());
            System.out.println("图书名称"+book.getName());
            System.out.println("总价格"+p.getSum());


        }



    }
